{include file='public/header' /}
<body>

    <div class="layui-fluid">

        <div class="layui-row">

            <form class="layui-form " enctype="multipart/form-data" id="file" style="margin: 50px;">

                <input type="hidden" name="id" value="{$info.id}">

                <input type="hidden" name="img" value="{$info.img}">
                <div class="layui-form-item">
                    <label for="phone" class="layui-form-label">
                        <span class="x-red">*</span>图片展示
                    </label>
                        <div class="layui-upload-drag" id="test10">
                          <p>点击上传，或将图片拖拽到此处</p>
                          <div id="uploadDemoView">
                            <hr>
                            <img src="{$info.img}" style="max-width: 196px; max-height: 124px;">
                          </div>
                        </div>

                 </div>



                <!-- 上级分类 -->
                <div class="layui-form-item">

                    <label class="layui-form-label" for="name">

                        <span class="x-red">*</span>服务名称

                    </label>

                    <div class="layui-input-block ">

                        <input type="text" name="name" lay-verify="name" autocomplete="off" placeholder="请输入服务项目名称" class="layui-input" value="{$info.name}">

                    </div>


                </div>


                <div class="layui-form-item">

                    <label class="layui-form-label" for="name">

                        <span class="x-red">

                            *

                        </span>

                        服务介绍

                    </label>

                    <div class="layui-input-block">
                        <textarea placeholder="请输入服务项目介绍" class="layui-textarea" name="content">{$info.content}</textarea>
                    </div>

                </div>


                <div class="layui-form-item" id="cost_price_div">

                    <label class="layui-form-label" for="price">

                        <span class="x-red">

                            *

                        </span>

                        服务费用

                    </label>

                    <div class="layui-input-inline">
                        <input autocomplete="off" class="layui-input" id="price" lay-verify="" name="price" placeholder="￥" type="text" value="{$info.price}">
                    </div>
                </div>


                 <div class="layui-form-item" id="cost_price_div">

                    <label class="layui-form-label" for="price">

                        <span class="x-red">

                            *

                        </span>

                        费用类型

                    </label>

                    <div class="layui-input-block">
                        <input type="radio" name="is_fixed" value="1" title="固定价格" {if $info.is_fixed == 1} checked="" {/if} lay-filter="projectFilter2">
                        <input type="radio" name="is_fixed" value="2" title="基数价格" {if $info.is_fixed == 2} checked="" {/if} lay-filter="projectFilter2">
                        
                    </div>
                </div>



                
                <div class="layui-form-item">

                    <label class="layui-form-label" for="L_repass">

                    </label>

                    <button class="layui-btn" id="submitBtn" lay-filter="add" lay-submit="" type="submit">

                        确定修改

                    </button>

                </div>

            </form>

        </div>

    </div>



    <script>
        layui.use('upload', function(){
          var $ = layui.jquery
          ,upload = layui.upload;
                 //拖拽上传 店铺logo
                  upload.render({
                    elem: '#test10'
                    ,url: '{:url("uploadfile/getfile")}' //改成您自己的上传接口
                    ,before: function(obj){
                      //预读本地文件示例，不支持ie8
                        obj.preview(function(index, file, result){
                        layui.$('#uploadDemoView').removeClass('layui-hide').find('img').attr('src', result);
    
                      });
                    }   
                     ,done: function(res){
                            $("input[name='img']").val(res.data.src); 
                        }
                  });

          });

    </script>





    <script>

        layui.config({
            base: '__ROOT__/static/admin/lib/layui/lay/modules/',
        })
        // 只需要引入multiSelect模块即可
        layui.use(['multiSelect'],function() {
            
        });

        layui.use(['form', 'layer', 'upload'], function() {

            $ = layui.jquery;

            var form = layui.form

            ,layer = layui.layer

            ,upload = layui.upload;
            
            //自定义验证规则

            form.verify({

                name: function(value) {

                    if (value.length < 2) {

                        return '昵称至少得2个字符啊';

                    }

                }

            });
        });



        //获取form表单的节点
          fileEle = document.getElementById('file');

          arr = [];

          //把value的值拿出来

          valEle = '';

          nulEle = '';


          $("#file").on("submit",function(){

            //阻止form默认提交
            var evt = event;

            evt.preventDefault();

            //得到formData

            var formData = new FormData($(this)[0]);

            $.ajax({

              url:"{:url('Service/edit')}",

              type:"post",

              async: false,

              cache: false,

              contentType: false,

              processData: false,

              data:formData,

              success:function(data){

                if (data.code == 1) {

                  layer.msg(data.message, {icon: 1,time: 1500});

                  setTimeout(function(){
                    //刷新父页面
                    window.parent.location.reload(); 
                    // 获得frame索引
                    var index = parent.layer.getFrameIndex(window.name); 
                    //关闭当前frame
                    parent.layer.close(index);

                  },1500);


                }else{

                  layer.msg('修改失败', {icon: 2,time: 1500});

                }

                

              }

            })

          })

    </script>

</body>

